package util

import "gitee.com/shiwjlinux/blog-web/db"

func AuthUserAndPassword(name, password string) *db.User {
	user := &db.User{}
	res := db.DB.Select("name", "password").Where("name=?", name).First(user)
	if res.RowsAffected == 0 {
		return nil
	}
	if !VerifyPassword(user.Password, password) {
		return nil
	}

	return user
}
